package me.pearjelly.dao.hibernate;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import me.pearjelly.dao.SelectorDao;
import me.pearjelly.model.Selector;

@Repository
public class SelectorDaoImpl extends AbstractDao implements SelectorDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<Selector> findByDomain(String domain) {
		try {
			return (List<Selector>) getHibernateTemplate().find(
					"from Selector s where s.domain=?", domain);
		} catch (DataAccessException e) {
			logger.error(e.getMessage());
			throw e;
		}
	}

	private static final Logger logger = LoggerFactory
			.getLogger(SelectorDaoImpl.class);
}
